<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-wcs__receivetask}">
      <wcs-form v-model="dataForm" :formList="formList" :table-column="tableColumn" :advanced="advanced"
        @check-change="checkChange" @changeAdvance="changeAdvance" @getDataList="getDataList" @getReset="getReset">
        <el-form-item>
          <el-button v-if="$hasPermission('wcs:receive-task:analyze')" type="primary" @click="trkHandle('REPT')">{{
            '指令解析'
          }}</el-button>
        </el-form-item>
        
      </wcs-form>
      <wcs-table ref="wcsTable" class="receiveTaskTable" v-model="dataForm" :page="page" :total="total" :limit="limit" :tableData="dataList"
        :table-column="column" :module-options="mixinViewModuleOptions" :dataListLoading="dataListLoading"
        :showSelection="true" @pageSizeChangeHandle="pageSizeChangeHandle"
        @pageCurrentChangeHandle="pageCurrentChangeHandle" @selectChangeHandle="selectChangeHandle" />
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from "@/mixins/view-module";
import debounce from "lodash/debounce";
import { formList, tableColumn } from './config'
import wcsTable from '@/components/wcs-table'
import wcsForm from '@/components/wcs-form'
import { trkHandle } from '@/utils/api'
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: "/wcs/receive-task/page",
        getDataListIsPage: true,
      },
      dataForm: {
        contNo: '',
        frmPos: '',
        toPos: '',
        trkType: ''
      },
      formList,
      tableColumn,
      column: [],
      advanced: false
    };
  },
  components: {
    wcsTable,
    wcsForm
  },
  methods: {
    //0.重置搜索框
    getReset() {
      this.dataForm = this.$options.data().dataForm;
    },
    trkHandle(operateType) {
      if (!this.trkId) {
        return this.$message({
          message: '请先选择任务！',
          type: 'warning',
          duration: 500
        })
      }
      const params = {
        operateType
      }
      trkHandle(params).then(({data: res}) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg)
        }
        this.$message({
          message: res.data,
          type: 'success',
          duration: 1000,
          onClose: () => {
                this.getDataList()
              }
        })
      })
    },
     // 单选
     selectChangeHandle(selection, row) {
      this.trkId = ''; //每次单选都重置id
      if (selection.length > 1) {
        this.$refs.wcsTable.$refs.Table.clearSelection()
        this.$refs.wcsTable.$refs.Table.toggleRowSelection(row)
      }
      if (selection.length != 0) {
        //只有当真正选中了目标主单才获取id
        //this.trkId = row.trkId;
      }
    }
  },
 
};
</script>
<style lang="scss" scoped>
/* 隐藏表头的全选框 */
::v-deep .trkTable thead .el-table-column--selection .cell {
  display: none;
}
</style>
<style>
.right-handle-group {
  float: right;
}
</style>


